f = None
try:
    f = open("test.txt", "a", encoding="utf-8")  # 绝对路径 写入 如果不存在文件 就创建
    f.write("你好\n")
    f.writelines(["321\n", "321\n"])
except Exception as e:
    print(e)
finally:
    if f:
        f.flush()
        f.close()
# 查看函数的帮助
print(help(open))